<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    $arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    // 1.数组去重
    let example = [...new Set($arr)];
    let example1 = Array.from(new Set($arr));
    console.log(example, example1);

    // 交集
    let arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    let arr2 = [3, 4, 5, 5];
    let result1 = Array.from(new Set(arr1)).filter(item => new Set(arr2).has(item));
    console.log(result1);

    // 并集
    let arr3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    let arr4 = [3, 4, 5, 5, 11];
    let result2 = Array.from(new Set([...arr3, ...arr4]));
    console.log(result2);

    // 差集
    let arr5 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    let arr6 = [3, 4, 5, 5, 11];
    let result3 = Array.from(new Set(arr5)).filter(item => !new Set(arr6).has(item));
    console.log(result3);




</script>

</html>